package com.yue.rpc;

import com.yue.rpc.RpcServiceTest;
import com.yue.rpc.TestMessage;
import com.yue.rpc.annotation.RpcReference;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zhangqiyue
 * @Description
 * @Date 2023/3/6 17:05
 */
@Component
public class RpcController {

    @RpcReference(version = "version1", group = "test1")
    private RpcServiceTest rpcService;

    public void test() throws InterruptedException {
        String testRpc = rpcService.testRpc(new TestMessage("ZQY", "111"));
        assert testRpc.equals("Test Description is 111");
//        Thread.sleep(30000);
//        Thread.sleep(20000);
        Thread.sleep(10000);
        long beginTime = System.currentTimeMillis();
        for (int i = 0; i < 10000; ++i) {
            rpcService.testRpc(new TestMessage("ZQY", "111"));
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - beginTime);
    }
}
